/** Operateindex.js By qijialin */
var myTab ={};

layui.config({
    base: 'webjar/plugins/js/'
}).use(['element', 'layer' , 'tab'], function() {
    var element = layui.element(),
        $ = layui.jquery,
        layer = layui.layer,
        tab = layui.tab({
            elem: '.admin-nav-card' //设置选项卡容器
        });
    myTab = tab;
    //iframe自适应
    $(window).on('resize', function() {
        var $content = $('.admin-nav-card .layui-tab-content');
        $content.height($(this).height() - 147);
        $content.find('iframe').each(function() {
            $(this).height($content.height());
        });
    }).resize();

     //手机设备的简单适配
    var treeMobile = $('.site-tree-mobile'),
        shadeMobile = $('.site-mobile-shade');
    treeMobile.on('click', function() {
        $('body').addClass('site-mobile');
    });
    shadeMobile.on('click', function() {
        $('body').removeClass('site-mobile');
    });

    //搜索流程按钮事件
    $('#showMsg').click(function () {
        //var tabData = {href: "http://www.qq.com", icon: "fa-navicon", title: "QQ"};
        //tab.tabAdd(tabData);

        layer.alert('酷毙了', {icon: 1,offset:'rb',shade: 0,time: 3000});

        var jsonStr = {'name':'aaaa','age':'20'}
        jsObj.printWeighLabel(JSON.stringify(jsonStr));
    });



});

/**
 * 激活tab页
 * 没有的打开新的tab页
 * 已打开的切换到tab页
 * 重置url 刷新数据
 * @param url
 * @param icon
 * @param title
 * @constructor
 */
function ActiveTab(url, icon, title){
    //打开或切换到tab
    var tabData = {href: url, icon: icon, title: title};
    myTab.tabAdd(tabData);


    //找tab
    $("cite").each(function(){
        if($(this).text() == title){
            //取tab对应的id
            var tabId = $(this).next("i").attr("data-id");
            //重置对应的html url 刷新
            $("iframe[data-id= '"+tabId+"']").attr("src",url);
        }
    });
}

